//
//  IssueNowAlertController.m
//  LianShangBao
//
//  Created by 主事丫环HU on 2020/9/2.
//  Copyright © 2020 主事丫环. All rights reserved.
//

#import "IssueNowAlertController.h"

@interface IssueNowAlertController ()
@property (weak, nonatomic) IBOutlet UILabel *balanceLabel;
@property (weak, nonatomic) IBOutlet UILabel *totalLabel;

@end

@implementation IssueNowAlertController
- (instancetype)init {
    if (self = [super initWithNibName:nil bundle:nil]) {
        self.modalPresentationStyle = UIModalPresentationCustom;
        self.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithWhite:0.5 alpha:0.5];
    
    self.balanceLabel.text = [NSString stringWithFormat:@"¥%@",self.balance];
    self.totalLabel.text = [NSString stringWithFormat:@"¥%.2f",self.total];
}
- (IBAction)confirmButtonClick:(UIButton *)sender {
    
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    param[@"userId"] = USER_ID;
    param[@"id"] = self.productID;
    param[@"num"] = self.count;
    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    [NetWorkTool POST:createOrder param:param success:^(id dic) {
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        [self dismissViewControllerAnimated:YES completion:nil];
        if (self.buySuccessfulClick) {
            self.buySuccessfulClick();
        }
    } other:^(id dic) {
        NSString *msg = dic[@"msg"];
        ShowToastWithText(msg);
        [MBProgressHUD hideHUDForView:self.view animated:YES];
    } fail:^(NSError *error) {
        [MBProgressHUD hideHUDForView:self.view animated:YES];
    } needUser:YES];
}

- (IBAction)cancelButtonClick:(UIButton *)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}


@end
